package com.mrogrape.notepad.activity.action.item;

import java.awt.event.ActionEvent;

import javax.swing.Action;
import javax.swing.JCheckBoxMenuItem;

import com.mrogrape.notepad.activity.MainFrame;
import com.mrogrape.notepad.activity.action.NotepadAction;
import com.mrogrape.notepad.data.ViewContext;
import com.mrogrape.notepad.resource.Settings;


public class ToggleToolbarVisibleMenuItemAction extends NotepadAction {

	/** serialVersionUID */
	private static final long serialVersionUID = -1L;

	public ToggleToolbarVisibleMenuItemAction(){

		super.putValue(Action.NAME, "Show Toolbar");
		super.putValue(Action.SHORT_DESCRIPTION, "Toggle toolbar visible.");
	}

	@Override
	public void actionPerformed(ActionEvent ae) {

		MainFrame frame = ViewContext.getMainFrame();
		JCheckBoxMenuItem item = (JCheckBoxMenuItem) ae.getSource();

		frame.setToolbarVisible(item.isSelected());
		Settings.getSettings().setShowToolbar(item.isSelected());
	}
}
